# import cv2
# # 读入灰度图像
# img = cv2.imread('img/car.jpg', cv2.IMREAD_GRAYSCALE)
#
# # 图像二值化
# threshold_value = 128
# (T, img_threshold) = cv2.threshold(img, threshold_value, 255, cv2.THRESH_BINARY)
#
# # 显示结果并保存
# cv2.imshow("img_threshold", img_threshold)
# cv2.imwrite('out/chepai.jpg', img_threshold)
#
#
# cv2.waitKey(0)


import cv2
import pytesseract
from PIL import Image

# 读入灰度图像
# img = cv2.imread('out/car.jpg', cv2.IMREAD_GRAYSCALE)
#
# # 图像二值化
# threshold_value = 128
# (T, img_threshold) = cv2.threshold(img, threshold_value, 255, cv2.THRESH_BINARY)
#
# # 显示结果并保存
# cv2.imshow("img_threshold", img_threshold)
# cv2.imwrite('out/car.jpg', img_threshold)

# 输出车牌
img = cv2.imread('out/car.jpg')
cv2.imshow("img",img)
string = pytesseract.image_to_string(img, lang='eng')
print("string is :", string)



cv2.waitKey(0)
